import 'package:fish_redux/fish_redux.dart';
import 'package:flutter/material.dart';
import '../../../app_files.dart';
import 'action.dart';
import 'state.dart';

Widget buildView(
    UserAccountState state, Dispatch dispatch, ViewService viewService) {
  return Scaffold(
    resizeToAvoidBottomPadding: false,
    appBar: myAppBar(viewService.context, title: '我的账号'),
    body: GestureDetector(
      child: Column(
        children: [
          Container(
            color: Colors.white,
            padding: EdgeInsets.symmetric(horizontal: 15),
            child: Column(
              children: [
                Container(
                  height: 50,
                  child: Row(
                    children: [
                      Text(
                        '手机号',
                        style: TextThemeConfig.Font14WithColor22,
                      ),
                      Expanded(child: Container()),
                      Text(
                        state.userInfo.mobile,
                        style: TextThemeConfig.Font14WithColor99,
                      ),
                    ],
                  ),
                  decoration: BoxDecoration(
                      border: Border(
                          bottom: BorderSide(color: ThemeConfig.separeColor))),
                ),
                Container(
                  height: 50,
                  child: Row(
                    children: [
                      Text(
                        '密码',
                        style: TextThemeConfig.Font14WithColor22,
                      ),
                      Expanded(
                        child: Container(
                          child: TextField(
                            textAlign: TextAlign.right,
                            controller: state.editingController,
                            style: TextStyle(
                                fontSize: 14, color: ThemeConfig.blackColor),
                            obscureText: true,
                            decoration: InputDecoration(
                              border: InputBorder.none,
                              hintText: "请输入您的密码",
                              hintStyle: TextStyle(
                                  fontSize: 14,
                                  color: ThemeConfig.black153Color),
                            ),
                            onChanged: (String str) {
                              if (str.length > ThemeConfig.passwordTextLength)
                                state.editingController.text = str.substring(
                                    0, ThemeConfig.passwordTextLength);
                            },
                          ),
                        ),
                      ),
                      Padding(
                        padding: EdgeInsets.only(
                          left: 8,
                        ),
                        child: Image.asset('images/right_arrow.png'),
                      ),
                    ],
                  ),
                ),
              ],
            ),
          ),
          Expanded(child: Container(
            child: Column(
              children: [Container(
                height: 50,
                margin: EdgeInsets.only(top: 88,left: 15,right: 15),
                decoration: BoxDecoration(
                  color: ThemeConfig.mainColor,
                  borderRadius: BorderRadius.all(Radius.circular(4)),
                ),
                child: InkWell(
                  child: Center(
                    child: Text('保存',style: TextThemeConfig.Font16WithWhite,),
                  ),
                  onTap: ()=> dispatch(UserAccountActionCreator.onSubmit()),
                ),
              )],
            ),
          ),),
        ],
      ),
      onTap: () => CommonUtils.closeKey(viewService.context),
      behavior: HitTestBehavior.translucent,
    ),
  );
}
